<?php
class RegistrationMgr
{  
    //注册组件
    function register(Lesson $lesson)
    {
        //处理该课程
        $notifier = Notifier::getNotifier();
        $notifier->inform("new lesson:cost ({$lesson->cost()}");
    }
}
abstract class Notifier
{   //只要通知类
    static function getNotifier()
    {
        if (rand(1, 2) == 1) {
            //随机发送这么diao吗
            return new MailNotifier();

        } else {
            return new TextNotifier();
        }
    }
    abstract function inform($message);
}
//具体
class MailNotifier extends Notifier
{
    function inform($message)
    {
        print "mail Nofification:{$message}<br>";
    }
}
class TextNotfifier extends Notifier
{
    function inform($message)
    {
        print "Text notification :{$message}<br>";
    } 
}                           
?>